import requests

url = 'https://ltsxmty.gtimg.com/B_A_YRAqlJgvVaYHglAxaQJVufxX2Mi_bNghT_LChc9r4TKI6-5ZqyuK4rHie9rnbtLBtrdfX1PaDKLyOna4WFlkX4xt6eUzgo8UHzjsbcI5f7X-vaYk2bgYE3PUrxayExVosJ41fLvj7e99U2A7o4Ug/svp_50001/6um2nuSqtq-RA-P8Y27MEEsw942T5-lH744WkatbOIS2_VR3mRYwf40Is5Xe7Mz4w-9jUWgROgxGQrA9u4JLGvg2-Byon1_zE0G3g-pMWGi5gQ_0Kh7vVFv4MeexFvS6S-g8AbXaZzH0yI5VLbr_IhW6betQkLfiMbAN-dhOQ8H_8ss3aRNup8NWW4Oi5YWiK-ZRwFRpKwl8_m8SHigEG9-9UKmH-VZ5tGBg3YWaP0nCM1qGL0nur0pXtvbB-5XK/szg_3467_50001_0bc3yyaquaab2qakdl3yafufbrwdbldaccsa.f306313.ts.m3u8?ver=4'
headers = {
    'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 SLBrowser/9.0.6.5061 SLBChan/105 SLBVPV/64-bit',
    'Cookie':
        'RK=qZnEdVPg0C; pgv_pvid=6179245110; fqm_pvqid=07f0ab31-a3a1-44f1-a36f-105de10bb256; qq_domain_video_guid_verify=f7da0a7a54218f14; o_cookie=2981702923; pac_uid=0_pBxHhnB3wZnnG; suid=user_0_pBxHhnB3wZnnG; _qimei_uuid42=1940a0930001008b23e949f58ef3a94220d5b98d16; _qimei_fingerprint=985f363a421c053055e49b2ec75d8caf; lcad_appuser=4BC2F81356564212; _qimei_q32=0363937a2cb78d09f38dff2c80655183; _qimei_q36=85050387ea18f25f838bef63300012d17807; ptcz=eff379f35d57efe3c7461bcc63e9fa3e5947705fab4cda4c73c6c81072ea9dd4; pgv_info=ssid=s8463836602; _qpsvr_localtk=0.9124714855401004; video_omgid=f7da0a7a54218f14; omgid=0_pBxHhnB3wZnnG; current-city-name=sh; _qimei_h38=92a7556823e949f58ef3a94202000007d1940a; lcad_o_minduid=bTMgjsjkoKaP5yhF5kh0KAHplHTidUAP; lcad_LPSJturn=0; lcad_LBSturn=123; lcad_LVINturn=940; lcad_LDERturn=111'
}
# data = {
#     'from': "pc",
#     'channel_id': "news_news_nchupin",
#     'device_id': "0_pBxHhnB3wZnnG",
#     'flush_num': 1,
#     'forward': "2",
#     'qimei36': "0_pBxHhnB3wZnnG"
# }
tss = []
berturl = 'https://ltsxmty.gtimg.com/B_fXrb0otmtGHxqhZ5HYDTdkHHKoh1NV50Y0Ussf0ap6YgSlLqJNJAF0udYFaBEQpZbHxnM5PlxgvZY-hPis4UUYYFik2H5bxL4KxXJJFtHwYAsZkVNPRFjKtdUPLKXzHQnZ8dGP0tNpU6vNiIOqCtNA/svp_50001/Wo6wZTCdS3q8khqLV4T1EPZZ3xsnnLGjwwBuq2IMt9wIjoJ09aM1vDNcDxSxN5Ywdby-YO_1UhwVaQNCBtq_4jEpToaskvQfgWymBVuCgXua2Ww-QlhKVwDaW7i2hWTGIn0H1U9RJ86lwbi8IiJfxavvXLkGVLqJypuSrtIfbtZYFY1wiAwj_XuLvVDTixPIohlJceCmBwRyRxwYJKwzdzJXdj4UYQb9znkvba3SCho/01_szg_4368_50001_0b53q4aq4aab6uapa5l3gjufbb6db2dqcdsa.f306313.1.ts?index=1&start=12000&end=24000&brs=352876&bre=694095&ver=4&token=298878793b7f8fea8b6a04370d8d8445'
htlm = requests.get(url, headers=headers)
for i in htlm.text.split('\n'):
    if "ts?index" in i:
        print(i)
        tss.append(i)

file = open('movie.mp4', 'wb')
for ts in tss:
    mov = berturl + ts
    move = requests.get(mov, headers=headers)
    file.write(move.content)

file.close()
